import _ from 'lodash'
export default {
  /**
   * 手机号码正则
   */
  mobile: /^[1][0-9]{10}$/,
  /**
   * async-validator 数值型自定义验证
   * @param {Object} rule async-validator
   * @param {*} value 表单值
   * @param {Function} callback async-validator
   */
  validatorNumber(rule, value, callback) {
    if (!value || value === 0) {
      return callback(new Error(rule.message))
    }
    callback()
  },
  /**
   * async-validator 布尔型自定义验证
   * @param {Object} rule async-validator
   * @param {*} value 表单值
   * @param {Function} callback async-validator
   */
  validatorBoolean(rule, value, callback) {
    if (_.isNil(value)) {
      return callback(new Error(rule.message))
    }
    callback()
  },
}
